package com.ruoyi.yanjing.constant;


import com.ruoyi.common.DateUtil;

import java.util.Date;

public class BizNo {
	
	public final static Long count_four = 4L;  //长度
	public final static Long count_six = 6L;  //长度
	
	public final static String ORDER_NO = "01";  //订单
	public final static String ORDER_PAYMENT_NO = "1"; //订单支付
	public final static String ORDER_SERVE_NO = "2";	 //订单售后
	public final static String ORDER_RETURN_NO = "3"; //订单退货
	public final static String ORDER_REFUND_NO = "4"; //订单退款
	
	
	public final static String USER_NO = "11"; //用户 
	public final static String USER_RECHARGE_NO = "13"; //用户充值
	public final static String USER_DRAW_NO = "14"; //用户提现
	public final static String USER_REVENUE_IN_NO = "15"; //用户提现
	public final static String USER_REVENUE_OUT_NO = "16"; //用户提现
	public final static String USER_RETUREN_NO = "19"; //用户退款
	
	
	 /**
	 * 根据ID设置成3位的字符串.
	 * @param id
	 * @return
	 */
	public static String getThreeId(String count) {
		String buID = "";
		if (count.length() == 1) {
			buID = "00" + count;
		}
		if (count.length() == 2) {
			buID = "0" + count;
		}
		return buID;
	}
	
	 /**
	 * 根据ID设置成3位的字符串.
	 * @param id
	 * @return
	 */
	public static String getId(String length,String id) {
		String buID = "";
		int count = 0;
		if(Integer.valueOf(length) > id.length()  ){
			count = Integer.valueOf(length) - id.length();
		}else{
			buID = id;
		}
		if(count > 0){
			for(int i=0;i<count;i++){
				buID += "0";
			}
			buID = buID + id;
		}
		return buID;
	}
	
	/**
	 * 根据参数来生成相应的业务编号.
	 * @param length 业务长度
	 * @param bizNo 业务编号类型
	 * @param count 个数
	 * @return
	 */
	public static String makeBizNum(Long length,String bizNo,Long count) {
		String dateString = DateUtil.format(new Date(), DateUtil.YMD_E);
		String buNo = dateString + bizNo + getId(String.valueOf(length),String.valueOf(count));
		return buNo;
	}
	
	/**
	 * 根据参数来生成相应的业务编号.
	 * @param length 业务长度
	 * @param bizNo 业务编号类型
	 * @param count 个数
	 * @return
	 */
	public static String makeBizNum(Long length,Long count) {
		String dateString = DateUtil.format(new Date(), DateUtil.YMD_E);	
		String buNo = dateString  + getId(String.valueOf(length),String.valueOf(count));
		return buNo;
	}
	
	
	public static void main(String args[]) {
		System.out.println(getId("6","21"));
//		System.out.println(makeBizNum(6L,"13",2L));
		
	}
	
}
